{% extends 'index.html' %}
{% block title %}
<title>图书添加</title>
{% endblock %}

{% block con %}
<div class="widget am-cf">
    <div class="widget-head am-cf">
        <div class="widget-title am-fl">图书录入</div>
        <div class="widget-function am-fr">
            <a href="" class="am-icon-cog"></a>
        </div>
    </div>
    <div class="widget-body am-fr">
        <form action="{{ url_for('admin.bookinsert') }}" method="POST" enctype="multipart/form-data" class="am-form tpl-form-line-form">
           
            <div class="am-form-group">
                <label for="user-name" class="am-u-sm-3 am-form-label">标题
                </label>
                <div class="am-u-sm-9">
                    <input type="text" placeholder="标题,必填" class="tpl-form-input" name="title">                
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-name" class="am-u-sm-3 am-form-label">作者
                </label>
                <div class="am-u-sm-9">
                    <input type="text" placeholder="作者,必填" class="tpl-form-input" name="suthor">                
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-name"  class="am-u-sm-3 am-form-label">价格
                </label>
                <div class="am-u-sm-9">
                    <input type="text" name="price" class="tpl-form-input" placeholder="价格,必填">                
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-name" class="am-u-sm-3 am-form-label">数量
                </label>
                <div class="am-u-sm-9">
                    <input type="text" placeholder="共余,必填" class="tpl-form-input" name="num">                
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-name" class="am-u-sm-3 am-form-label">INBS
                </label>
                <div class="am-u-sm-9">
                    <input type="text" placeholder="INBS,必填" class="tpl-form-input" name="isbn">                
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-name" class="am-u-sm-3 am-form-label">评分
                </label>
                <div class="am-u-sm-9">
                    <input type="text" placeholder="评分,选填" class="tpl-form-input" name="score">                
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-name" class="am-u-sm-3 am-form-label">出版社
                </label>
                <div class="am-u-sm-9">
                    <input type="text" placeholder="出版社,必填" class="tpl-form-input" name="publisher">                
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-name" class="am-u-sm-3 am-form-label">备注
                </label>
                <div class="am-u-sm-9">
                    <input type="text" placeholder="备注,选填" class="tpl-form-input" name="explain">                
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-name" class="am-u-sm-3 am-form-label">上架时间
                </label>
                <div class="am-u-sm-9">
                    <input type="text" placeholder="默认当前时间,选填" class="tpl-form-input" name="addtime">                
                </div>
            </div>
           
            <div class="am-form-group">
                <label for="user-weibo" class="am-u-sm-3 am-form-label">封面</label>
                <div class="am-u-sm-9">
                    <div class="am-form-group am-form-file">
                        <div class="tpl-form-file-img">
                        <img src="/static/img/0.png" alt="" id="fileimg" style="width:129px;height:170px ">
                        </div>
                        <button type="button" class="am-btn am-btn-danger am-btn-sm">
                            <i class="am-icon-cloud-upload"></i>添加封面图片
                        </button>
                        <input id="doc-form-file" name="image" type="file" multiple="">
                    </div>
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-intro" class="am-u-sm-3 am-form-label">图书简介</label>
                <div class="am-u-sm-9">
                    <textarea class="" placeholder="简介,选填" rows="10" name="recommend"></textarea>
                </div>
            </div>

            <div class="am-form-group">
                <label for="user-intro" class="am-u-sm-3 am-form-label">作者简介</label>
                <div class="am-u-sm-9">
                    <textarea class="" placeholder="作者,选填" rows="10" name="authorinfo"></textarea>
                </div>
            </div>
            
            <div class="am-form-group">
                <label for="user-intro" class="am-u-sm-3 am-form-label">目录</label>
                <div class="am-u-sm-9">
                    <textarea class="" placeholder="目录,选填" rows="10" name="catalog"></textarea>
                </div>
            </div>

            <div class="am-form-group">
                <div class="am-u-sm-9 am-u-sm-push-3">
                    <button class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">

    // 显示上传图片
    $('input[name=image]').change(function(){
        var t = this
        // 拿到原始对象
        var file = t.files[0],
        reader = new FileReader();
        reader.readAsDataURL(file);
        // 将加载成功的文件,渲染到页面
        reader.onload = function(){
            $('#fileimg').attr('src',reader.result)
        }
    })


</script>


{% endblock %}